package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try (
                Connection conn = DBUtil.getConnection();
        ) {
            Statement statement = conn.createStatement();
            String sql = "SELECT id,name,salary,title "+
                         "FROM teacher";
            ResultSet re = statement.executeQuery(sql);
            while (re.next()) {
                int id = re.getInt("id");
                String name = re.getString("name");
                double salary = re.getDouble("salary");
                String title = re.getString("title");
                System.out.println(id+" "+name+" "+salary+" "+title);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
